const express = require('express')
const router = express.Router()
const pool = require('../pool')

// http://127.0.0.1:3000/users/changepraise
router.get('/:sid', (req, res, next) => {
  var obj = req.params
  pool.query(
    'update qnls_strategy set praise=praise+1 where sid = ?',
    [obj.sid],
    (err, result) => {
      if (err) {
        return next(err)
      }
      if (result.changedRows === 0) {
        res.send({ code: 400, msg: '点赞失败,没有该数据', data: result })
      } else {
        res.send({ code: 200, mag: '点赞成功', data: result })
      }
    }
  )
})

module.exports = router
